"use strict";

const Controller = require('../common/admin')

class GoodsController extends Controller {

  tableName = 'goods'

  async getGoodsList () {
    let goodsData = await this.consult()

    this.tableName = 'goods_sku'
    let skuPm = []
    goodsData.forEach((goodsItem) => {
      skuPm.push(this.consult({goods_id: goodsItem.goods_id}))
    });
    let skuList = await Promise.all(skuPm)

    goodsData.forEach((goodsItem, index) => {
      goodsItem.skuList = skuList[index]
    })

    // console.log('goodsList', result);
    this.resData(0, '商品列表获取成功', goodsData)
  }


}

module.exports = GoodsController